package com.briup.cms.exception;

import com.briup.cms.utils.Message;
import com.briup.cms.utils.MessageUtil;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author wood
 */
@RestController
public class NotFoundException implements ErrorController {

    @RequestMapping(value = {"/error"})
    public Message error(HttpServletRequest request) {
        return MessageUtil.error("您访问的资源地址不存在："+request.getRequestURI());
    }

    /**
     * The return value from this method is not used; the property `server.error.path`
     * must be set to override the default error page path.
     *
     * @return the error path
     * @deprecated since 2.3.0 in favor of setting the property `server.error.path`
     */
    @Override
    public String getErrorPath() {
        return "/error";
    }
}
